package com.cskaoyan.order.constant;

public enum OrderRetCode {
    SUCCESS                             ("000000", "成功"),

    REQUISITE_PARAMETER_NOT_EXIST       ("005073", "必要的参数不能为空"),

    INIT_ORDER_EXCEPTION                ("005093","初始化订单异常"),
    PIPELINE_RUN_EXCEPTION              ("005094","系统异常"),
    SHIPPING_DB_SAVED_FAILED            ("005095","物流信息保存数据库失败"),
    DB_SAVE_EXCEPTION                   ("005096","数据保存异常"),
    DB_EXCEPTION                        ("005097", "数据库异常"),
    SYSTEM_TIMEOUT                      ("005098", "系统超时"),
    SYSTEM_ERROR                        ("005099", "系统错误"),
    ALL_PRODUCTS_STOCK_NOT_INIT         ("005100", "所有订单商品库存均未初始化"),
    PART_OF_PRODUCTS_STOCK_NOT_INIT     ("005101", "部分订单商品库存未初始化"),
    CALL_CART_PRODUCT_BY_USERID_CLEAR_FAIL     ("005102", "根据用户订单清除购物车失败"),
    CALL_PRODUCT_DETAIL_FAIL     ("005103", "获取商品详情失败"),

    ITEM_SOLD_OUT    ("005104","商品已下架！"),
    ITEM_COUNT_LIMIT    ("005105","商品超买了！"),
    CANCEL_ORDER_ERROR   ("005106","取消订单异常！请联系客服！"),
    DELETE_ORDER_ERROR   ("005107","删除订单异常！请联系客服！");
    private String code;
    private String message;

    OrderRetCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * Getter method for property <tt>code</tt>.
     *
     * @return property value of code
     */
    public String getCode() {
        return code;
    }

    /**
     * Setter method for property <tt>code</tt>.
     *
     * @param code value to be assigned to property code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>message</tt>.
     *
     * @return property value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Setter method for property <tt>message</tt>.
     *
     * @param message value to be assigned to property message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessage(String code) {
        for (OrderRetCode s : OrderRetCode.values()) {
            if (null == code)
                break;
            if (s.code.equals(code)) {
                return s.message;
            }
        }
        return null;
    }
}
